<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Shopping Cart</title>
</head>
<body>
    <h1>Welcome to Ebook Shop!</h1>
    {% include 'ebooks/menu.html' %}
    <h2>Shopping Cart</h2>
    {% if cart %}
        <table>
            <tr>
                <th>Title</th>
                <th>Author</th>
                <th>Price</th>
                <th>Remove</th>
            </tr>
            {% for item in cart %}
            <tr>
                <td>{{ item.book.title }}</td>
                <td>{{ item.book.author }}</td>
                <td>${{ item.book.price }}</td>
                <td>
                    <form method="POST" action="{% url 'remove_from_cart' item.book.id %}">
                        {% csrf_token %}
                        <button type="submit">Remove</button>
                    </form>
                </td>
            </tr>
            {% endfor %}
        </table>
    {% else %}
        <p>Your cart is empty.</p>
    {% endif %}
    <h2>Shipping Information</h2>
    {% if error_message %}
        <p>{{ error_message }}</p>
    {% endif %}
    <form method="POST" action="{% url 'cart' %}">
        {% csrf_token %}
        {{ checkout_form.as_p }}
        <button type="submit">Place Order</button>
    </form>
</body>
</html>